<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\model;

/**
 * 菜单模型
 */
class Menu extends AdminBase
{
    
    /**
     * 隐藏状态获取器
     */
    public function getIsHideTextAttr($value = null, $data = [])
    {
        
        $is_hide = [DATA_DISABLE => '否', DATA_NORMAL => '是'];
        
        // 优先从 $data 读取，其次回退到 getData()，最后默认 DATA_DISABLE
        $raw = array_key_exists('is_hide', $data)
            ? $data['is_hide']
            : (is_array($this->getData()) && array_key_exists('is_hide', $this->getData()) ? $this->getData()['is_hide'] : DATA_DISABLE);
        
        return $is_hide[$raw] ?? $is_hide[DATA_DISABLE];
    }
}
